home *** CD-ROM | disk | FTP | other *** search
/ Programming an RTS Game with Direct3D / Programming an RTS Game with Direct3D.iso / Examples / Chapter 14 / Example 14.1 / skinnedMesh.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-07-17  |  1.4 KB  |  61 lines

  1. #ifndef SKINNED_MESH
  2. #define SKINNED_MESH
  3.  
  4. #include <windows.h>
  5. #include <d3dx9.h>
  6. #include <string>
  7. #include <vector>
  8. #include "debug.h"
  9.  
  10. #define ANIM_STILL 4
  11. #define ANIM_IDLE 3
  12. #define ANIM_RUN 2
  13. #define ANIM_ATTACK 1
  14. #define ANIM_DIE 0
  15.  
  16. struct BONE: public D3DXFRAME
  17. {
  18.     D3DXMATRIX CombinedTransformationMatrix;
  19. };
  20.  
  21. struct BONEMESH: public D3DXMESHCONTAINER
  22. {
  23.     ID3DXMesh* OriginalMesh;
  24.     std::vector<D3DMATERIAL9> materials;
  25.     std::vector<IDirect3DTexture9*> textures;
  26.  
  27.     DWORD NumAttributeGroups;
  28.     D3DXATTRIBUTERANGE* attributeTable;
  29.     D3DXMATRIX** boneMatrixPtrs;
  30.     D3DXMATRIX* boneOffsetMatrices;
  31.     D3DXMATRIX* currentBoneMatrices;
  32. };
  33.  
  34. class SKINNEDMESH
  35. {
  36.     public:
  37.         SKINNEDMESH();
  38.         ~SKINNEDMESH();
  39.         void Load(char fileName[], IDirect3DDevice9 *Dev);
  40.         void Render(BONE *bone);
  41.  
  42.         BONE* FindBone(char name[]);
  43.         void SetPose(D3DXMATRIX world, ID3DXAnimationController* animControl, float time);
  44.         int SetAnimation(char name[]);
  45.         void SetAnimation(int index);
  46.         float GetAnimationDuration(int index);
  47.         std::vector<std::string> GetAnimations();
  48.         ID3DXMesh* GetCurrentMesh(BONE *bone);
  49.  
  50.         ID3DXAnimationController* GetAnimationControl();
  51.  
  52.     private:
  53.         void UpdateMatrices(BONE* bone, D3DXMATRIX *parentMatrix);
  54.         void SetupBoneMatrixPointers(BONE *bone);
  55.  
  56.         IDirect3DDevice9 *m_pDevice;
  57.         D3DXFRAME *m_pRootBone;
  58.         ID3DXAnimationController *m_pAnimControl;
  59. };
  60.  
  61. #endif